package com.chy.设计模式;

import org.junit.Test;

public class 装饰者模式 {
    @Test
    public void test() {
        Component component = new ConcreteComponent();
        component.operation();
        System.out.println("---------------");
        Component component1 = new ConcreteDecorator( component );
        component1.operation();
    }

interface Component{
    void operation();
}

class ConcreteComponent implements Component{

    @Override
    public void operation() {
        System.out.println("基础功能：拍照");
    }
}

abstract class Decorator implements Component{
    Component component;

    public Decorator(Component component) {
        this.component = component;
    }
}

class ConcreteDecorator extends Decorator{

    public ConcreteDecorator(Component component) {
        super(component);
    }

    @Override
    public void operation() {
        component.operation();
        System.out.println("扩展功能：美颜");
    }
}


}
